import { _decorator, Component, Node, Vec2 } from 'cc';
import { AdHorizontal } from '../../platform/AdHorizontal';
import { AdVertical } from '../../platform/AdVertical';
import { CustomOptions } from '../../platform/CustomOptions';
import { platformUtil } from '../../platform/platformUtil';
import { BaseObject } from '../modules/baseObject';
import { memoryConfig } from '../modules/memoryConfig';
import { UiForm } from './uiForm';
const { ccclass, property } = _decorator;

@ccclass('baseAdForm')
export class baseAdForm extends UiForm {

    start() {

    }


    onEnable() {
        let zs_chaping = memoryConfig.instance.getIntKey("zs_chaping", 0);
        if (zs_chaping == 0) {
            return;
        }
        if (zs_chaping > 0) {
            let interIndex = memoryConfig.instance.getIntKey("inter_index", 0);
            if ((interIndex + 1) % zs_chaping == 0) {
                platformUtil.currentPlatform.showInter();
            }
            interIndex++;
            memoryConfig.instance.setKey("inter_index", interIndex);
            return;
        }
        if (zs_chaping == -1) {
            platformUtil.currentPlatform.showInter();
            return;
        }
    }

    public showFloatCustomAd() {
        let options = CustomOptions.New(AdHorizontal.LEFT, AdVertical.TOP, new Vec2(0, 105), null, null) as CustomOptions;
        platformUtil.currentPlatform.showCustomAd(options, 0, () => { });
    }


    public showTopCustomAd() {
        let options = CustomOptions.New(AdHorizontal.CENTER, AdVertical.TOP, new Vec2(0, 0), null, null) as CustomOptions;
        platformUtil.currentPlatform.showCustomAd(options, 1, () => { });
    }

    public hideTopCustomAd() {
        platformUtil.currentPlatform.hideCustomAd(1);
    }

    public showBottomCustomAd() {
        let options = CustomOptions.New(AdHorizontal.CENTER, AdVertical.BOTTOM, new Vec2(0, 0), null, null) as CustomOptions;
        platformUtil.currentPlatform.showCustomAd(options, 3, () => { });
    }

    public hideBottomCustomAd() {
        platformUtil.currentPlatform.hideCustomAd(3);
    }



    onDisable() {

    }

    update(deltaTime: number) {

    }
}

